package com.sun.alen.mapper;

import com.sun.alen.entity.Exam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExamMapper {
    @Insert("INSERT INTO exam( examId,examGrade,studentId,courseId) " +
            "VALUES( #{examId}, #{examGrade},#{studentId},#{courseId})")
    boolean add(Exam exam);

    @Update("UPDATE exam set examGrade = #{examGrade}, studentId = #{studentId},courseId = #{courseId} " +
            "where examId = #{examId}")
    boolean update(Exam exam);

    @Delete("DELETE * from exam where examId = #{id}")
    boolean delete(String id);

    @Select("SELECT * from exam limit #{start},#{pageSize}")
    List<Exam> list(int start, Integer pageSize);

    @Select("SELECT count(*) from exam")
    Integer count();

    @Select("Select * from exam where studentId = #{studentId}")
    List<Exam> searchByStudent(int studentId);

    @Select("SELECT * from exam where courseId =#{courseId}")
    List<Exam> searchByCourse(int courseId);

    @Select("select * from exam where courseId = #{courseId}")
    List<Exam> searchByCourseId(Integer courseId);

    @Select("select * from exam where studentId = #{studentId}")
    List<Exam> searchByStudentId(Integer studentId);
}
